package com.example.personalizededucationsystem.repository;

import com.example.personalizededucationsystem.model.Class;
import com.example.personalizededucationsystem.model.ClassMember;
import com.example.personalizededucationsystem.model.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface ClassMemberRepository extends JpaRepository<ClassMember, Long> {
    @Query("SELECT cm.myClass FROM ClassMember cm WHERE cm.student.userId = :studentId")
    List<Class> findClassesByStudentId(@Param("studentId") Long studentId);

    boolean existsByStudentAndMyClass(User student, Class myClass);

    long countByMyClass(Class myClass);


    List<ClassMember> findByMyClass(Class myClass);
}